package com.example.su_shi_tan_core

import com.example.su_shi_tan_bas_lib.global.AppGlobals
import com.example.su_shi_tan_core.db.LogInTokenManager
import okhttp3.Interceptor
import okhttp3.Response

class SuShiTanRequestInterceptor : Interceptor {
    override fun intercept(chain: Interceptor.Chain): Response {
        val credentials = LogInTokenManager.tokenManager.getLogInToken() ?: ""
        val basic = AppGlobals.getApplication()
            .getString(R.string.baseBearerAuth, credentials)
        val original = chain.request()
        val request = original.newBuilder()
            .header("Authori-zation", basic)
            .build()
        return chain.proceed(request)
    }
}